#!/bin/sh

# Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT?
do
	# Get its remaining capacity and charge status.
	capacity=$(cat "$battery"/capacity) || break
	status=$(sed "s/[Dd]ischarging/ /;s/[Nn]ot charging/ﮣ/;s/[Cc]harging/⚡/;s/[Uu]nknown/ /;s/[Ff]ull/⚡/" "$battery"/status)

	 [ "$capacity" -le 10 ] && [ "$status" = " " ] && status=" "
	 [ "$capacity" -le 40 ] && [ "$status" = " " ] && status=" "
	 [ "$capacity" -le 50 ] && [ "$status" = " " ] && status=" "
	 [ "$capacity" -le 90 ] && [ "$status" = " " ] && status=" "

	printf "%s%s%% " "$status" "$capacity"
done
